package com.xucy.springboot.designmodel.structural.composite;

/**
 * @Author xucy Container HashMap中putAll  ArrayList-addAll  Mybatis-SqlNode
 * @Date 2019-07-19 10:43
 * @Description 组合模式 组合模式用于整体-部分之间的关系，客户端不需要关注层次的差异，方便对整个层次进行控制
 *   业务场景：有一个课程目录，往目录里面放课程
 **/

public class Test {

    public static void main(String[] args) {
        CourseComponent courseJava=new Course("java",11);

        CourseComponent courseCatalog=new CourseCatalog("课程目录",1);
        courseCatalog.add(courseJava);

        CourseComponent courseCatalog1=new CourseCatalog("go目录",2);

        CourseComponent courseGoBook=new Course("goBook",11);
        CourseComponent courseGoVideo=new Course("goVideo",11);
        courseCatalog1.add(courseGoBook);
        courseCatalog1.add(courseGoVideo);

        courseCatalog.add(courseCatalog1);

        courseCatalog.print();
    }
}
